//银银间回购
#pragma once
#include <core/sync/lock.h>
#include <qbmessage/include/message_bond.h>
#include <qbprotocol/include/SSIRSModel.h>
#include <qbprotocol/include/SSMsgStruct.h>
#include <QString>
#include <set>

class MessageReceiver;
class FIIRSData {
public:
	typedef std::map<int, xIrsMiddlePriceUnit_c> MAP_DATA;
	typedef std::vector<int> VCT_IDS;
	enum enType
	{
		emNull = -1,
		emOutrightRepo_1Y = 0,
		emOutrightRepo_5Y,
		emOutrightShibor_1Y,
		emOutrightShibor_5Y,
		emOutrightCount
	};

	struct iCache
	{
		const std::string ksGoodOutright = "OUTRIGHT";
		const std::string ksTypeRepo = "REPO";
		const std::string ksTypeShibor = "SHIBOR";
		const std::string ksTerm1Y = "1Y";
		const std::string ksTerm5Y = "5Y";

		VCT_IDS m_vctType;
		VCT_IDS m_vctFlash;

		time_t m_tLastUpdateTime;
		QString m_strUpdateTime;
		MAP_DATA m_mapData;
		iCache()
		{
			m_tLastUpdateTime = 0;
			m_mapData.clear();
		}

		void clear();
		void initial();
		bool update(xIrsMiddlePriceList_c* pdata);
	};

public:
	FIIRSData();
	qb::base::Mutex& getLock() { return m_lock; };

	void clear();
	MAP_DATA& getData();
	VCT_IDS& getOrder();
	VCT_IDS& getFlash();
	QString getLastUpdate();

	void reqData(MessageReceiver* msgRecv);
	bool onReceive(int32_t funcId, const qb::SSAckMsg& msg);

private:
	iCache m_iCache;
	qb::base::Mutex m_lock;
};

